/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FrafficGeneratorSystemPreference.java
 *
 * Created on 18.06.2010, 11:56:15
 */

package md.shaman;

import md.shaman.configs.Config;
import md.shaman.icons.PNGPacket;
import org.jdesktop.application.Action;

/**
 *
 * @author AlexandruC
 */
public class TrafficGeneratorSystemPreference extends javax.swing.JDialog {

    /** Creates new form FrafficGeneratorSystemPreference */
    public TrafficGeneratorSystemPreference(java.awt.Frame parent) {
        super(parent);
        initComponents();
    }
     @Action public void closeSystemPreference() {
        dispose();
    }
    @Action public void saveSystemPreference() {
       Config.setGeneralRefrash(Integer.parseInt(refreshIntervalSpinner.getValue().toString()));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        refreshIntervalLabel = new javax.swing.JLabel();
        refreshIntervalSpinner = new javax.swing.JSpinner();
        saveButton = new javax.swing.JButton();
        closeButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(md.shaman.TrafficGeneratorApp.class).getContext().getResourceMap(TrafficGeneratorSystemPreference.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setIconImages(PNGPacket.Preferences.getImages());
        setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
        setName("Form"); // NOI18N
        setResizable(false);

        refreshIntervalLabel.setLabelFor(refreshIntervalSpinner);
        refreshIntervalLabel.setText(resourceMap.getString("refreshIntervalLabel.text")); // NOI18N
        refreshIntervalLabel.setName("refreshIntervalLabel"); // NOI18N

        refreshIntervalSpinner.setModel(new javax.swing.SpinnerNumberModel(1, 1, 10000, 1));
        refreshIntervalSpinner.setName("refreshIntervalSpinner"); // NOI18N
        refreshIntervalSpinner.setValue(Config.getGeneralRefrash());

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(md.shaman.TrafficGeneratorApp.class).getContext().getActionMap(TrafficGeneratorSystemPreference.class, this);
        saveButton.setAction(actionMap.get("saveSystemPreference")); // NOI18N
        saveButton.setText(resourceMap.getString("saveButton.text")); // NOI18N
        saveButton.setToolTipText(resourceMap.getString("saveButton.toolTipText")); // NOI18N
        saveButton.setName("saveButton"); // NOI18N

        closeButton.setAction(actionMap.get("closeSystemPreference")); // NOI18N
        closeButton.setText(resourceMap.getString("closeButton.text")); // NOI18N
        closeButton.setName("closeButton"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(refreshIntervalLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(refreshIntervalSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(93, 93, 93)
                        .addComponent(saveButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(closeButton)))
                .addContainerGap(90, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(refreshIntervalLabel)
                    .addComponent(refreshIntervalSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 50, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(saveButton)
                    .addComponent(closeButton))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                TrafficGeneratorSystemPreference dialog = new TrafficGeneratorSystemPreference(new javax.swing.JFrame());
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton closeButton;
    private javax.swing.JLabel refreshIntervalLabel;
    private javax.swing.JSpinner refreshIntervalSpinner;
    private javax.swing.JButton saveButton;
    // End of variables declaration//GEN-END:variables

}
